#include <QCoreApplication>
#include <QStringList>
#include <QFile>
#include <QDataStream>
#include <QDebug>


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    qDebug() << "Writing ...";
    QFile file("/home/luchu/file.txt");

    file.open(QIODevice::WriteOnly);
    QDataStream out(&file); // we will serialize the data into the file

    QVariant v(123);
    int x = v.toInt();
    qDebug() << v;
    out << v;

    v = QVariant("Hello");
    v = QVariant(QObject::tr("Hello"));
    int y = v.toInt();
    QString s = v.toString();
    out << v;
    qDebug() << v;
    file.flush();
    file.close();

    qDebug() << "Reading...";
    file.open(QIODevice::ReadOnly);
    QDataStream in(&file);
    in >> v;
    int z = v.toInt();
    qDebug() << v;


    in >> v;
    if (v.canConvert<QStringList>()){
        qDebug() << v.toStringList();
    }

    file.close();
    return a.exec();
}
